
package com.amigo.online.provider.manager.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.amigo.online.common.base.controller.BaseController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.provider.manager.model.entity.AdvNearbyApplyTbl;
import com.amigo.online.provider.manager.model.entity.AdvNearbySourceTbl;
import com.amigo.online.provider.manager.result.AdvNearbyInfo;
import com.amigo.online.provider.manager.service.AdvNearbyApplyTblService;
import com.amigo.online.provider.manager.service.AdvNearbySourceTblService;

/**
 * <code>AdvNearbyController.java</code>
 * <p>
 * : 附近广告controller
 * </p>
 * <p>
 *
 * @author LuChen
 * @version 1.0
 * @company Amigo
 * @time 2018年11月26日 下午6:33:09
 * @lastUpdate 无
 * </p>
 */
@RestController
@RequestMapping(value = "/advNearbyApplyTbl", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class AdvNearbyController extends BaseController {


    @Autowired
    private AdvNearbyApplyTblService advNearbyApplyTblService;

    @Autowired
    private AdvNearbySourceTblService advNearbySourceTblService;


    /**
     * 添加广告基本信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @PostMapping(value = "/addNearAdv")
    public ResponseEntity<Response> addAdvNearbyApplySource(@RequestBody AdvNearbyApplyTbl advNearbyApplyTbl) {
        AdvNearbyApplyTbl re = advNearbyApplyTblService.addAdvNearbyApply(advNearbyApplyTbl);
        return success(re);
    }


    /**
     * 添加广告资源
     *
     * @param advNearbySourceTbl
     * @return
     */
    @PostMapping(value = "/addNearAdvSource")
    public ResponseEntity<Response> addAdvNearbyApply(@RequestBody AdvNearbySourceTbl advNearbySourceTbl) {
        AdvNearbySourceTbl re = advNearbySourceTblService.addAdvNearbySourceApply(advNearbySourceTbl);
        return success(re);
    }


    /**
     * 修改附近广告基本信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @PostMapping(value = "/updateNearbyAdvInfo")
    public ResponseEntity<Response> updateNearbyAdv(@RequestBody AdvNearbyApplyTbl advNearbyApplyTbl) {
        boolean re = advNearbyApplyTblService.updateAdvNearbyApply(advNearbyApplyTbl);
        return success(re);
    }


    /**
     * 修改广告资源
     *
     * @param advNearbySourceTbl
     * @return
     */
    @PostMapping(value = "/updateNearbyAdvSourceInfo")
    public ResponseEntity<Response> updateNearbyAdvSource(@RequestBody AdvNearbySourceTbl advNearbySourceTbl) {
        boolean re = advNearbySourceTblService.updateNearbyAdvSource(advNearbySourceTbl);
        return success(re);
    }


    /**
     * 根据不同条件查询附近的广告基本信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @PostMapping("/getNearbyAdvInfo")
    public ResponseEntity<Response> getNearbyAdvInfo(@RequestBody AdvNearbyApplyTbl advNearbyApplyTbl) {
        JSONObject re = advNearbyApplyTblService.findNearbyAdv(advNearbyApplyTbl);
        return success(re);
    }

    /**
     * 根据id查询广告的详细信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @GetMapping("/getNearbyAdvDetailInfo")
    public ResponseEntity<Response> getNearbyAdvDetailInfo(Long id) {
        AdvNearbyInfo info = advNearbyApplyTblService.findNearbyAdvDetailInfo(id);
        return success(info);
    }


    /**
     * 根据id删除附近广告信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @DeleteMapping("/deleteNearbyAdv")
    public ResponseEntity<Response> deleteNearbyAdvSource(@RequestBody AdvNearbyApplyTbl advNearbyApplyTbl) {
        boolean re = advNearbyApplyTblService.deleteById(advNearbyApplyTbl);
        return success(re);
    }


    /**
     * 审核附近广告
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @PostMapping("/check")
    public ResponseEntity<Response> checkNearbyAdv(@RequestBody AdvNearbyApplyTbl advNearbyApplyTbl) {
        boolean re = advNearbyApplyTblService.checkAdv(advNearbyApplyTbl);
        return success(re);
    }


}

